public class Test3 {
        // 判断是否为素数的函数
        public static boolean isPrime(int n) {
            if (n <= 1) {
                return false;
            }
            for (int i = 2; i * i <= n; i++) {
                if (n % i == 0) {
                    return false;
                }
            }
            return true;
        }

        public static void main(String[] args) {
            int count = 0;
            for (int i = 1; i <= 20000; i++) {
                if (isPrime(i)) {
                    System.out.print(i + " ");
                    count++;
                    if (count % 5 == 0) {
                        System.out.println();
                    }
                }
            }
        }
}
